package com.ruoyi.college.controller;

import java.util.List;
import com.ruoyi.common.utils.uuid.IdUtils;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.college.domain.College;
import com.ruoyi.college.service.ICollegeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学院信息管理Controller
 *
 * @author chenxl
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/college/college")
public class CollegeController extends BaseController
{
    @Autowired
    private ICollegeService collegeService;

    /**
     * 查询学院信息管理列表
     */
   // @PreAuthorize("@ss.hasPermi('college:college:list')")
    @GetMapping("/list")
    public TableDataInfo list(College college)
    {
       // startPage();
        List<College> list = collegeService.selectCollegeList(college);
        return getDataTable(list);
    }

    /**
     * 导出学院信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('college:college:export')")
    @Log(title = "学院信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, College college)
    {
        List<College> list = collegeService.selectCollegeList(college);
        ExcelUtil<College> util = new ExcelUtil<College>(College.class);
        util.exportExcel(response, list, "学院信息管理数据");
    }

    /**
     * 获取学院信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('college:college:query')")
    @GetMapping(value = "/{collegeId}")
    public AjaxResult getInfo(@PathVariable("collegeId") String collegeId)
    {
        return success(collegeService.selectCollegeByCollegeId(collegeId));
    }

    /**
     * 新增学院信息管理
     */
    @PreAuthorize("@ss.hasPermi('college:college:add')")
    @Log(title = "学院信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody College college)
    {
        college.setCollegeId(IdUtils.fastSimpleUUID());
        return toAjax(collegeService.insertCollege(college));
    }

    /**
     * 修改学院信息管理
     */
    @PreAuthorize("@ss.hasPermi('college:college:edit')")
    @Log(title = "学院信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody College college)
    {
        return toAjax(collegeService.updateCollege(college));
    }

    /**
     * 删除学院信息管理
     */
    @PreAuthorize("@ss.hasPermi('college:college:remove')")
    @Log(title = "学院信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{collegeIds}")
    public AjaxResult remove(@PathVariable String[] collegeIds)
    {
        return toAjax(collegeService.deleteCollegeByCollegeIds(collegeIds));
    }
    /**
     * 根据学院部门id列表获取对应的id列表
     * */
}
